import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//1.引入element-plus组件库
import ElementPlus, {ElMessage} from 'element-plus'
import 'element-plus/dist/index.css'

//5.1修改elementPlus默认中文
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'


const BASE_URL = 'http://localhost:8080';
//<Script>标签设置全局对象
window.BASE_URL = BASE_URL;

const app = createApp(App);

//<template> 标签设置全局对象
app.config.globalProperties.BASE_URL = BASE_URL;





app.use(ElementPlus,{locale: zhCn}).use(store).use(router).mount('#app')


const debounce = (fn, delay) => {
    let timer = null;
    return function () {
        let context = this;
        let args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function () {
            fn.apply(context, args);
        }, delay);
    }
}
const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 16);
        super(callback);
    }
}